Cloud Scheduler
list
$ gcloud scheduler jobs list だと OIDC token とか見れない
--format=json するとより詳細な情報が得られる
code:list.json
[
{
"lastAttemptTime": "2020-03-16T01:00:00.334888Z",
"name": "projects/pokutuna-playground/locations/asia-northeast1/jobs/kick-airpodspro-R224",
"pubsubTarget": {
"data": "******"
"topicName": "projects/pokutuna-playground/topics/check-stock-apple-store"
},
"retryConfig": {
"maxBackoffDuration": "3600s",
"maxDoublings": 16,
"maxRetryDuration": "0s",
"minBackoffDuration": "5s"
},
"schedule": "0/20 7,8,9,10 * * *",
"scheduleTime": "2020-03-16T22:00:00.528532Z",
"state": "ENABLED",
"status": {},
"timeZone": "Asia/Tokyo",
"userUpdateTime": "2020-02-26T00:38:21Z"
},
...
]
Cloud Functions を叩く
--allow-unauthenticated でない Functions を叩く
roles/cloudfunctions.invoker が必要
--oidc-service-account-email に Function を実行可能なサービスアカウントを渡す
code:create.sh
gcloud scheduler jobs create http kick-load \
--time-zone "Asia/Tokyo" \
--schedule="23 4 * * *" \
--uri="$(FUNCTION_URL)" \
--headers="Content-Type=application/json" \
--http-method="POST" \
--message-body='{ "action": "load" }' \
--oidc-service-account-email=pokutuna-dev@appspot.gserviceaccount.com
--oidc-token-audience には Function の URL が自動で入る
むしろ余計なもん入れないほうがいいっぽい